Skip to content

create the kafka foundations#1

Merged
Juniorbarry26 merged 1 commit into
mainfrom
feat/topics
May 17, 2026
Merged

create the kafka foundations#1
Juniorbarry26 merged 1 commit into
mainfrom
feat/topics

Conversation

@Juniorbarry26

@Juniorbarry26 Juniorbarry26 commented May 16, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added REST API endpoint for sending messages to a message queue.
    • Added Kafka consumer and producer infrastructure for message processing.
  • Chores

    • Initialized Maven project configuration and wrapper.
    • Added Docker Compose setup for local development environment with Kafka and ZooKeeper.
    • Configured project build exclusions and Git settings.
  • Tests

    • Added basic application startup test.

Review Change Stack

@Juniorbarry26
Juniorbarry26 requested review from Copilot and removed request for Copilot May 16, 2026 02:36
@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR establishes a complete Spring Boot Kafka demo application with Maven build configuration, Docker Compose infrastructure, producer and consumer services, and a REST API endpoint. The application accepts messages via HTTP POST and publishes them to a Kafka topic that is consumed and logged.

Changes

Spring Boot Kafka Demo Application

Layer / File(s) Summary
Maven build tooling and project setup
.gitattributes, .gitignore, .mvn/wrapper/maven-wrapper.properties, mvnw, mvnw.cmd, pom.xml
Maven wrapper scripts (shell and Windows) configured for Maven 3.9.15 with distribution download, platform detection, archive extraction, and checksum validation. Project targets Java 17 with Spring Boot 4.0.6, Kafka, WebMVC, and Lombok dependencies. Annotation processors and build exclusions configured.
Docker Compose infrastructure
docker-compose.yml
ZooKeeper and Kafka services using Confluent images v7.5.0, broker and client port exposure, inter-service dependencies, and environment configuration for broker ID, ZooKeeper connection, advertised listeners, and replication settings.
Spring Boot application bootstrap and Kafka topic
src/main/java/com/alsainey/kafka_demo/KafkaDemoApplication.java, src/main/java/com/alsainey/kafka_demo/config/KafkaTopicConfig.java
KafkaDemoApplication with @SpringBootApplication and main method. KafkaTopicConfig bean creates "test-topic" Kafka topic with 1 partition and 1 replica.
Kafka producer and consumer services
src/main/java/com/alsainey/kafka_demo/producer/KafkaProducer.java, src/main/java/com/alsainey/kafka_demo/consumer/KafkaConsumer.java
KafkaProducer injects KafkaTemplate and publishes messages to "test-topic". KafkaConsumer registers @KafkaListener on "test-topic" in group "test-group" to consume and log messages.
REST API endpoint
src/main/java/com/alsainey/kafka_demo/rest/MessageController.java
MessageController mapped to /api/1/messages POST endpoint accepts String request body, invokes KafkaProducer.sendMessage(), and returns HTTP 200 success response.
Spring configuration and tests
src/main/resources/application.yaml, src/test/java/com/alsainey/kafka_demo/KafkaDemoApplicationTests.java
application.yaml sets spring.application.name and configures Kafka bootstrap servers, consumer group, deserializers/serializers, and producer retry/timeout settings. KafkaDemoApplicationTests verifies Spring context loads with @SpringBootTest.

Sequence Diagram

sequenceDiagram
  participant Client as HTTP Client
  participant API as MessageController
  participant Producer as KafkaProducer
  participant Kafka as Kafka Broker
  participant Consumer as KafkaConsumer
  Client->>API: POST /api/1/messages (message body)
  API->>Producer: sendMessage(message)
  Producer->>Kafka: publish to test-topic
  Kafka->>Consumer: deliver message
  Consumer->>Consumer: log message
  API->>Client: 200 OK "Message queued successfully"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A Spring Boot hop through Kafka's queue so bright,
Producer and consumer dance in the night,
With Maven's swift wrapper and Docker's embrace,
This demo app finds its rightful place! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'create the kafka foundations' accurately describes the main objective of the changeset, which establishes a complete Kafka-based Spring Boot project with producer, consumer, and infrastructure setup.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.mvn/wrapper/maven-wrapper.properties:
- Around line 1-3: Add a distributionSha512Sum property to the Maven wrapper
properties to verify the downloaded archive integrity: update the
.mvn/wrapper/maven-wrapper.properties by adding the
distributionSha512Sum=<official SHA-512 checksum for
apache-maven-3.9.15-bin.zip> alongside the existing wrapperVersion,
distributionType, and distributionUrl entries so the wrapper will validate the
downloaded archive using the official SHA-512 checksum.

In `@src/main/java/com/alsainey/kafka_demo/config/KafkaTopicConfig.java`:
- Around line 4-9: The class KafkaTopicConfig is annotated with `@Configurable`
(AspectJ weaving) so its `@Bean` methods won't be registered; replace
`@Configurable` with Spring's `@Configuration` to ensure the `@Bean` factory methods
are discovered and loaded into the application context (i.e., change the class
annotation from `@Configurable` to `@Configuration` so the `@Bean` methods in
KafkaTopicConfig are properly registered).

In `@src/main/java/com/alsainey/kafka_demo/consumer/KafkaConsumer.java`:
- Line 19: The log call in KafkaConsumer that does log.info(format("Message
consumed: %s", message)) exposes full message payloads; change it to avoid
logging raw message content at INFO level by logging only non-sensitive metadata
(e.g., topic, partition, offset, key) or by redacting/sanitizing the message,
and if payload inspection is needed keep the full message at DEBUG level (e.g.,
use log.debug for the full message) so replace the current log.info usage
accordingly referencing the KafkaConsumer class, the log variable and the
message variable.

In `@src/main/java/com/alsainey/kafka_demo/producer/KafkaProducer.java`:
- Around line 18-21: Change sendMessage to return the future produced by
kafkaTemplate.send so callers can observe success/failure: update the signature
of sendMessage(...) to return the producer future type returned by
kafkaTemplate.send(...) (e.g., CompletableFuture/
ListenableFuture<SendResult<...>> depending on your KafkaTemplate generics) and
return kafkaTemplate.send("test-topic", message) instead of discarding it; then
update MessageController to consume that future and map success to 200 OK and
failures to an appropriate error response so send result failures propagate to
the HTTP client. Ensure you reference the existing sendMessage method and
kafkaTemplate.send call and adapt generics to match the KafkaTemplate used.

In `@src/main/java/com/alsainey/kafka_demo/rest/MessageController.java`:
- Around line 20-24: In MessageController (the REST handler that accepts
`@RequestBody` String message and calls kafkaProducer.sendMessage), add input
validation to reject null or blank messages: check message for null or
message.trim().isEmpty() before calling kafkaProducer.sendMessage and if blank
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(...) (400) with an
explanatory message; otherwise proceed to call
kafkaProducer.sendMessage(message) and return the existing 200 response.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b372cbbf-1593-49b2-b28f-993b63e94d47

📥 Commits

Reviewing files that changed from the base of the PR and between 829099b and 5efbcb1.

📒 Files selected for processing (14)
  • .gitattributes
  • .gitignore
  • .mvn/wrapper/maven-wrapper.properties
  • docker-compose.yml
  • mvnw
  • mvnw.cmd
  • pom.xml
  • src/main/java/com/alsainey/kafka_demo/KafkaDemoApplication.java
  • src/main/java/com/alsainey/kafka_demo/config/KafkaTopicConfig.java
  • src/main/java/com/alsainey/kafka_demo/consumer/KafkaConsumer.java
  • src/main/java/com/alsainey/kafka_demo/producer/KafkaProducer.java
  • src/main/java/com/alsainey/kafka_demo/rest/MessageController.java
  • src/main/resources/application.yaml
  • src/test/java/com/alsainey/kafka_demo/KafkaDemoApplicationTests.java

Comment on lines +1 to +3
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/apache-maven-3.9.15-bin.zip

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

url="$(awk -F= '$1=="distributionUrl"{print $2}' .mvn/wrapper/maven-wrapper.properties)"
echo "distributionUrl=$url"

echo "Official SHA256 (from repository sidecar):"
curl -fsSL "${url}.sha256"

echo
echo "Configured checksum line (should exist):"
grep -n '^distributionSha256Sum=' .mvn/wrapper/maven-wrapper.properties || true

Repository: Juniorbarry26/kafka

Length of output: 292


🏁 Script executed:

# Try alternative methods to find official SHA256 for Maven 3.9.15
echo "=== Checking Maven Central directly ==="
# Try the base URL without .sha256
curl -fsSL -I "https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/apache-maven-3.9.15-bin.zip"

echo -e "\n=== Checking for .asc (GPG signature) file ==="
curl -fsSL -I "https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/apache-maven-3.9.15-bin.zip.asc"

echo -e "\n=== Checking for checksums.txt ==="
curl -fsSL -I "https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/checksums.txt"

echo -e "\n=== Checking Apache Archives for checksum ==="
curl -fsSL -I "https://archive.apache.org/dist/maven/maven-3/3.9.15/binaries/apache-maven-3.9.15-bin.zip.sha512"

echo -e "\n=== Listing what's available in Maven Central for 3.9.15 ==="
curl -fsSL "https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/" 2>/dev/null | grep -oP 'href="[^"]*"' | head -20 || true

Repository: Juniorbarry26/kafka

Length of output: 2682


🏁 Script executed:

echo "=== Fetching official SHA512 from Apache Archives ==="
curl -fsSL "https://archive.apache.org/dist/maven/maven-3/3.9.15/binaries/apache-maven-3.9.15-bin.zip.sha512"

echo -e "\n=== Fetching SHA512 from Maven Central ==="
curl -fsSL "https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/apache-maven-3.9.15-bin.zip.sha512"

echo -e "\n=== Checking Maven Wrapper documentation and source ==="
# Look for Maven wrapper configuration documentation
find . -name "*wrapper*" -o -name "*.md" | grep -i readme || true
ls -la .mvn/ 2>/dev/null || true

Repository: Juniorbarry26/kafka

Length of output: 651


🏁 Script executed:

echo "=== Checking Maven wrapper files ==="
ls -la .mvn/wrapper/

echo -e "\n=== Current maven-wrapper.properties content ==="
cat .mvn/wrapper/maven-wrapper.properties

echo -e "\n=== Searching for Maven wrapper documentation ==="
find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.xml" \) -exec grep -l "distributionSha256Sum\|distributionSha512Sum" {} \; 2>/dev/null || echo "No matches found"

echo -e "\n=== Checking pom.xml or maven-wrapper plugin config ==="
grep -A 20 -B 5 "maven-wrapper\|distributionSha" ./pom.xml 2>/dev/null || echo "Not found in pom.xml"

Repository: Juniorbarry26/kafka

Length of output: 629


🌐 Web query:

Maven wrapper properties distributionSha256Sum distributionSha512Sum supported

💡 Result:

The Maven Wrapper supports both SHA-256 and SHA-512 checksum verification for the Maven distribution and the Maven Wrapper JAR [1][2][3]. The following properties can be configured in the.mvn/wrapper/maven-wrapper.properties file: - distributionSha256Sum: The expected SHA-256 checksum of the Maven distribution [4][2]. - wrapperSha256Sum: The expected SHA-256 checksum of the maven-wrapper.jar [4][2]. - distributionSha512Sum: The expected SHA-512 checksum of the Maven distribution [1][3]. - wrapperSha512Sum: The expected SHA-512 checksum of the maven-wrapper.jar [1][3]. Support for SHA-512 checksums was introduced to align with the checksum formats published by the Apache Maven project, as Maven distributions are primarily published with SHA-512 checksums rather than SHA-256 [1][5]. While SHA-256 remains supported for backward compatibility, SHA-512 is the recommended approach for verifying modern Maven distributions [1]. When using these properties, the Maven Wrapper will validate the downloaded artifact against the provided checksum before execution [2][6]. If the checksum does not match, the wrapper will fail to prevent the execution of potentially compromised or corrupted files [1][6]. Note that checksum validation is not supported for the Maven Daemon (mvnd) [3].

Citations:


Add distributionSha512Sum to verify Maven distribution integrity.

Line 3 downloads an executable archive, but checksum verification is not configured. This leaves the wrapper without content-integrity pinning. Apache Maven officially publishes SHA-512 checksums (not SHA-256); configure verification using the official checksum:

 wrapperVersion=3.3.4
 distributionType=only-script
 distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/apache-maven-3.9.15-bin.zip
+distributionSha512Sum=251c676eb88684d6dd86c666817979d256a335c31ad34ab0e1df17eeca1cd504a6c890e906a46d04e51cc7a4fb02f33a75971ef750558034e0a81c257be02267
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/apache-maven-3.9.15-bin.zip
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.15/apache-maven-3.9.15-bin.zip
distributionSha512Sum=251c676eb88684d6dd86c666817979d256a335c31ad34ab0e1df17eeca1cd504a6c890e906a46d04e51cc7a4fb02f33a75971ef750558034e0a81c257be02267
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.mvn/wrapper/maven-wrapper.properties around lines 1 - 3, Add a
distributionSha512Sum property to the Maven wrapper properties to verify the
downloaded archive integrity: update the .mvn/wrapper/maven-wrapper.properties
by adding the distributionSha512Sum=<official SHA-512 checksum for
apache-maven-3.9.15-bin.zip> alongside the existing wrapperVersion,
distributionType, and distributionUrl entries so the wrapper will validate the
downloaded archive using the official SHA-512 checksum.

Comment thread src/main/java/com/alsainey/kafka_demo/config/KafkaTopicConfig.java

@KafkaListener(topics = "test-topic", groupId = "test-group")
public void consumeMessage(String message) {
log.info(format("Message consumed: %s", message));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid logging raw message payloads at INFO level.

Line 19 logs the full message body, which can leak PII/secrets into logs.

✅ Proposed fix
- log.info(format("Message consumed: %s", message));
+ log.info("Message consumed (length={})", message == null ? 0 : message.length());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
log.info(format("Message consumed: %s", message));
log.info("Message consumed (length={})", message == null ? 0 : message.length());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/alsainey/kafka_demo/consumer/KafkaConsumer.java` at line
19, The log call in KafkaConsumer that does log.info(format("Message consumed:
%s", message)) exposes full message payloads; change it to avoid logging raw
message content at INFO level by logging only non-sensitive metadata (e.g.,
topic, partition, offset, key) or by redacting/sanitizing the message, and if
payload inspection is needed keep the full message at DEBUG level (e.g., use
log.debug for the full message) so replace the current log.info usage
accordingly referencing the KafkaConsumer class, the log variable and the
message variable.

Comment on lines +18 to +21
public void sendMessage(String message) {
log.info(format("Sending message: %s", message));
kafkaTemplate.send("test-topic", message);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

For the Spring Kafka version used by this project, what is the exact return type of KafkaTemplate.send(...), and what is the recommended way to handle publish failures?

💡 Result:

For the Spring Kafka version used by your project (Spring Kafka’s KafkaTemplate API): 1) Exact return type of KafkaTemplate.send(...) KafkaTemplate.send(...) returns a CompletableFuture of SendResult: CompletableFuture<SendResult<K, V>> [1][2] 2) Recommended way to handle publish failures Handle failures asynchronously by attaching a completion callback to the returned future (e.g., whenComplete / callback), and react when the future completes exceptionally (or when you call get(...) with a timeout). Spring Kafka’s documentation shows registering a callback on the returned CompletableFuture to receive either the SendResult or an exception. [2][3] If you need strict “only return success to the client when the broker acknowledged the send”, the docs also recommend blocking only by waiting on the future, ideally with a timeout (future.get(...) / with timeout) and handling ExecutionException (send failure) separately. [3] Caveat: there are producer-side failures that can be thrown immediately, and others delivered via the future completing exceptionally; using the future result/callback is the recommended approach because it captures both outcomes. [4][2]

Citations:


🏁 Script executed:

# Find build configuration files to determine Spring Kafka version
fd -e pom.xml -e build.gradle -e gradle.properties -e "*.gradle.kts" | head -5

Repository: Juniorbarry26/kafka

Length of output: 45


🏁 Script executed:

# Check the exact content at the specified lines in the file
cat -n src/main/java/com/alsainey/kafka_demo/producer/KafkaProducer.java | head -30

Repository: Juniorbarry26/kafka

Length of output: 773


🏁 Script executed:

# Search for all kafkaTemplate.send calls in the codebase to understand the pattern
rg "kafkaTemplate\.send" --type java -n

Repository: Juniorbarry26/kafka

Length of output: 183


🏁 Script executed:

# Search more broadly for build configuration files
find . -type f \( -name "pom.xml" -o -name "build.gradle" -o -name "build.gradle.kts" \) 2>/dev/null

Repository: Juniorbarry26/kafka

Length of output: 73


🏁 Script executed:

# Also check parent directories or alternative locations
ls -la | grep -E "build|gradle|pom|maven"

Repository: Juniorbarry26/kafka

Length of output: 121


🏁 Script executed:

# Read the pom.xml to find Spring Kafka version
cat pom.xml

Repository: Juniorbarry26/kafka

Length of output: 2976


🏁 Script executed:

# Search for all calls to sendMessage method
rg "sendMessage" --type java -n

Repository: Juniorbarry26/kafka

Length of output: 407


🏁 Script executed:

# Check if there's a controller that calls this producer
fd -e java -path "*/controller/*" | head -10

Repository: Juniorbarry26/kafka

Length of output: 232


🏁 Script executed:

# Read the MessageController to understand the full context
cat -n src/main/java/com/alsainey/kafka_demo/rest/MessageController.java

Repository: Juniorbarry26/kafka

Length of output: 1061


Return the send result so failures can be propagated to the caller.

Line 20 discards the CompletableFuture<SendResult<K, V>> returned by kafkaTemplate.send(), making it impossible to detect or handle publish failures. The HTTP response at line 24 of MessageController returns 200 OK regardless of whether the Kafka send succeeds or fails, giving clients false confidence that the message was enqueued.

Modify sendMessage() to return the future and let the controller map the result to the HTTP response status. This way, clients can distinguish between successful enqueue and failures.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/alsainey/kafka_demo/producer/KafkaProducer.java` around
lines 18 - 21, Change sendMessage to return the future produced by
kafkaTemplate.send so callers can observe success/failure: update the signature
of sendMessage(...) to return the producer future type returned by
kafkaTemplate.send(...) (e.g., CompletableFuture/
ListenableFuture<SendResult<...>> depending on your KafkaTemplate generics) and
return kafkaTemplate.send("test-topic", message) instead of discarding it; then
update MessageController to consume that future and map success to 200 OK and
failures to an appropriate error response so send result failures propagate to
the HTTP client. Ensure you reference the existing sendMessage method and
kafkaTemplate.send call and adapt generics to match the KafkaTemplate used.

Comment on lines +20 to +24
@RequestBody String message
) {
kafkaProducer.sendMessage(message);

return ResponseEntity.ok("Message queued successfully");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Reject blank messages before publishing.

Line 20–24 forwards request body without validation; blank payloads should return 400 Bad Request.

✅ Proposed fix
     public ResponseEntity<String> sendMessage(
             `@RequestBody` String message
     ) {
+        if (message == null || message.isBlank()) {
+            return ResponseEntity.badRequest().body("Message must not be blank");
+        }
         kafkaProducer.sendMessage(message);
 
         return ResponseEntity.ok("Message queued successfully");
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@RequestBody String message
) {
kafkaProducer.sendMessage(message);
return ResponseEntity.ok("Message queued successfully");
public ResponseEntity<String> sendMessage(
`@RequestBody` String message
) {
if (message == null || message.isBlank()) {
return ResponseEntity.badRequest().body("Message must not be blank");
}
kafkaProducer.sendMessage(message);
return ResponseEntity.ok("Message queued successfully");
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/alsainey/kafka_demo/rest/MessageController.java` around
lines 20 - 24, In MessageController (the REST handler that accepts `@RequestBody`
String message and calls kafkaProducer.sendMessage), add input validation to
reject null or blank messages: check message for null or
message.trim().isEmpty() before calling kafkaProducer.sendMessage and if blank
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(...) (400) with an
explanatory message; otherwise proceed to call
kafkaProducer.sendMessage(message) and return the existing 200 response.

@Juniorbarry26
Juniorbarry26 merged commit 7d99bf6 into main May 17, 2026
2 checks passed
@Juniorbarry26
Juniorbarry26 deleted the feat/topics branch May 17, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant